import os
all_size = 0
def dir_size(dir_name):
    global all_size
    file_list = os.listdir(dir_name)
    for file in file_list:
        file_path = os.path.join(dir_name, file)
        if os.path.isfile(file_path):
            size = os.path.getsize(file_path)
            all_size += size
        else:
            dir_size(file_path)

dir_size('C://Users//Xl//Desktop//dir_size_test')
print(all_size)

